﻿@model BrnMall.Web.StoreAdmin.Models.StaffListModel
@using BrnMall.Manager.Domain.AddressBook

@section header{
<title>订单列表-订单管理</title>
<link type="text/css" rel="stylesheet" href="/admin_store/css/site.css"/>
<script type="text/javascript" src="/admin_store/scripts/jquery.js"></script>
<script type="text/javascript" src="/admin_store/scripts/showlist.js"></script>
<script type="text/javascript" src="/admin_store/scripts/staff/staff.js"></script>
    <style type="text/css">
        .logo { float:left; margin-right:5px;width:60px;height:60px;}
        .ship-type{border: 1px solid #ff8427;color: #555;border-radius: 2px;padding-left: 2px;padding-right: 2px;color: #ff8427;}
       body {
          background-color: #F6F6F6;
        }

        .container {
          width: 1000px;
          margin: auto;
        }

        .container-lft {
          float: left;
        }

        .container-rgt {
          float: right;
        }

        .nav-rank ul {
          padding-left: 0px;
        }

        .nav-rank {
          background-color: white;
          box-shadow: 0px 3px 0px 0px #F3F4F6;
          /*下边阴影  */
        }

        .nav-rank ul li {
          list-style-type: none;
        }

        a {
          text-decoration: none;
        }

        .nav-rank-name {
          height: 30px;
          width: 200px;
          padding-left: 20px;
          font-size: 12px;
          line-height: 30px;
          overflow: hidden;
          cursor: pointer;
          position: relative;
        }

        .nav-rank-name:hover {
          height: 30px;
          width: 200px;
          padding-left: 20px;
          font-size: 12px;
          line-height: 30px;
          background-color: #F5F7FA;
          /*指鼠标在链接*/
        }

        .nav-rank-name:hover .nav-rank-right {
          display: block;
        }

        .nav-rank-content {
          margin: 0px;
          display: none;
        }

        .tow {
          padding-left: 5px;
        }

        .three {
          padding-left: 10px;
        }

        .on {
          background-color: #F8F9FB;
          color: #1AAD19;
        }

        .nav-rank-img {
          height: 11px;
          width: 12px;
          position: absolute;
          top: 10px;
          left: 5px;
          transition: 0.5s;
          -moz-transition: 0.5s;
          /* Firefox 4 */
          -webkit-transition: 0.5s;
          /* Safari and Chrome */
          -o-transition: 0.5s;
          /* Opera */
        }

        .rotate_img {
          transform: rotate(90deg);
          -ms-transform: rotate(90deg);
          /* Internet Explorer */
          -moz-transform: rotate(90deg);
          /* Firefox */
          -webkit-transform: rotate(90deg);
          /* Safari 和 Chrome */
          -o-transform: rotate(90deg);
          /* Opera */
        }

        .nav-rank-right {
          float: right;
          height: 100%;
          display: table-cell;
          vertical-align: middle;
          padding-right: 10px;
          display: none;
        }

        .nav-rank-right-item {
          vertical-align: middle;
          margin-right: 5px;
        }

        .tan {
          height: 100%;
          width: 100%;
          display: none;
        }

        .mu {
          height: 100%;
          width: 100%;
          background-color: black;
          opacity: 0.5;
          position: fixed;
        }

        .window {
          height: 240px;
          width: 360px;
          position: fixed;
          top: 10%;
          left: 50%;
          right: 0px;
          margin-left: -180px;
          opacity: 0.2;
          background-color: white;
          animation: changeWind 0.25s;
          -moz-animation: changeWind 0.25s;
          /* Firefox */
          -webkit-animation: changeWind 0.25s;
          /* Safari and Chrome */
          -o-animation: changeWind 0.25s;
          /* Opera */
          animation-fill-mode: forwards;
        }

        @@keyframes changeWind {
          from {
            opacity: 0.2;
            top: 10%;
          }
          to {
            opacity: 1;
            top: 15%;
          }
        }

        @@-moz-keyframes changeWind
        /* Firefox */

          {
          from {
            opacity: 0.2;
            top: 10%;
          }
          to {
            opacity: 1;
            top: 15%;
          }
        }

        @@-webkit-keyframes changeWind
        /* Safari and Chrome */

          {
          from {
            opacity: 0.2;
            top: 10%;
          }
          to {
            opacity: 1;
            top: 15%;
          }
        }

        @@-o-keyframes changeWind
        /* Opera */

          {
          from {
            opacity: 0.2;
            top: 10%;
          }
          to {
            opacity: 1;
            top: 15%;
          }
        }

        .window-header {
          height: 55px;
          width: 90%;
          margin: auto;
          border-bottom: 1px solid #EAEAEA;
          display: flex;
          flex-direction: row;
          justify-content: space-between;
          align-items: center;
          font-size: 18px;
        }

        .window-body {
          height: 120px;
          width: 80%;
          margin: auto;
          display: flex;
          flex-direction: row;
          justify-content: flex-start;
          align-items: center;
        }

        .window-body-ipt {
          height: 40px;
          width: 200px;
          border: 1px solid #EAEAEA;
          border-radius: 5px;
          display: flex;
          justify-content: flex-start;
          align-items: center;
          padding-left: 10px;
        }

        .window-body-ipt input {
          height: 80%;
          width: 80%;
          border: 0;
          outline: none;
        }

        .window-foot {
          width: 100%;
          margin: auto;
          display: flex;
          flex-direction: row;
          justify-content: flex-end;
          align-items: center;
        }

        .window-close {
          height: 40px;
          width: 74px;
          border: 1px solid #EAEAEA;
          border-radius: 5px;
          text-align: center;
          line-height: 40px;
          color: black;
          font-size: 16px;
          margin-right: 10px;
        }

        .window-check {
          height: 40px;
          width: 74px;
          border: 1px solid #EAEAEA;
          border-radius: 5px;
          text-align: center;
          line-height: 40px;
          color: white;
          font-size: 16px;
          background-color: #1AAD19;
          margin-right: 10px;
        }

        .reduce {
          display: flex;
          flex-direction: row;
          justify-content: flex-start;
          align-items: center;
        }

        .btn-rec {
          height: 30px;
          width: 64px;
          line-height: 30px;
          font-size: 14px;
        }

        .list-header {
          height: 100px;
          width: 760px;
        }

        .list-header-tp-lft {
          font-size: 12px;
          color: #A2A19F
        }

        .list-header-tp {
          display: flex;
          flex-direction: row;
          justify-content: space-between;
          align-items: center;
        }

        .list-header-tp-rgt span {
          margin-left: 10px;
          font-size: 12px;
          color: #FF7B28;
        }

        .list-header-mid {
          display: flex;
          flex-direction: row;
          justify-content: space-between;
          align-items: center;
          margin-top: 5px;
        }

        .list-header-mid-lft {
          display: flex;
          flex-direction: row;
          justify-content: space-between;
          align-items: center;
        }

        .list-header-mid-lft-item {
          height: 25px;
          width: 60px;
          border: 1px solid #FF7B28;
          border-radius: 5px;
          font-size: 12px;
          color: #FF7B28;
          text-align: center;
          line-height: 25px;
          margin-right: 5px;
          cursor: pointer;
        }

        .list-header-mid-rgt {
          display: flex;
          flex-direction: row;
          justify-content: space-between;
          align-items: center;
        }

        .list-header-btm {
          display: flex;
          flex-direction: row;
          justify-content: flex-start;
          align-items: center;
          margin-top: 5px;
        }

        .list-header-btm-ipt {
          height: 30px;
          width: 200px;
          padding-left: 5px;
          outline: none;
        }

        .list-btn {
          height: 36px;
          width: 80px;
          display: flex;
          flex-direction: row;
          justify-content: center;
          align-items: center;
          background-color: #FF7B28;
          color: white;
          border-top-right-radius: 5px;
          border-bottom-right-radius: 5px;
        }

        .sou-img {
          height: 24px;
          width: 24px;
          margin-right: 5px;
        }

        .onitem {
          color: white;
          background-color: #FF7B28;
        }
    </style>
}

@section body{
<h1 class="rightH1">
    微信小程序 &gt; 部门人员 &gt; <span class="rightH1-cur">部门列表</span> 
<div class="clear"></div>
</h1>
@using (Html.BeginForm("stafflist", "staff"))
{
    <div class="container">
        <div class="container-lft">
            <div class="nav-rank">
                @foreach ( Department dep in Model.depList) {
                    if (dep.Parentid == 0)
                    {
                        <text>
                        <div class="nav-rank-name" data-id="@dep.Id">
                            <span>@dep.Name</span>
                            <img class="nav-rank-img" src="/admin_store/images/staff/1.png" alt="">
                            <div class="nav-rank-right">
                                <img class="nav-rank-right-item" src="/admin_store/images/staff/2.png" alt="" onclick="changeBar(this)">
                                <img class="nav-rank-right-item" src="/admin_store/images/staff/3.png" alt="" onclick="addBar(this)">
                                <img class="nav-rank-right-item" src="/admin_store/images/staff/4.png" alt="" onclick="reduceBar(this)">
                            </div>
                        </div>
                        </text>
                        foreach (Department deps in Model.depList)
                        {
                            if (dep.Id == deps.Parentid)
                            {
                                <text>
                                    <ul class="nav-rank-content one">
                                        <li>
                                            <div class="nav-rank-name " data-id="@deps.Id">
                                                <span class="tow"> @deps.Name</span>
                                                <img class="nav-rank-img" src="/admin_store/images/staff/1.png" alt="">
                                                <div class="nav-rank-right">
                                                    <img class="nav-rank-right-item" src="/admin_store/images/staff/2.png" data-id="@deps.Id" alt="" onclick="changeBar(this)">
                                                    <img class="nav-rank-right-item" src="/admin_store/images/staff/3.png" alt="" onclick="addBar(this)">
                                                    <img class="nav-rank-right-item" src="/admin_store/images/staff/4.png" alt="" onclick="reduceBar(this)">
                                                </div>
                                            </div>
                                            @foreach (Department depss in Model.depList) {
                                                if (deps.Id == depss.Parentid)
                                                {
                                                    <text>
                                                    <ul class="nav-rank-content tow">
                                                        <li>
                                                            <div class="nav-rank-name " data-id="@depss.Id">
                                                                <span class="three"> @depss.Name</span>
                                                                <img class="nav-rank-img" src="~/admin_store/images/staff/1.png" alt="" hidden="hidden">
                                                                <div class="nav-rank-right">
                                                                    <img class="nav-rank-right-item" src="/admin_store/images/staff/2.png" alt="" onclick="changeBar(this)">
                                                                    <img class="nav-rank-right-item" src="/admin_store/images/staff/3.png" alt="" onclick="addBar(this)">
                                                                    <img class="nav-rank-right-item" src="/admin_store/images/staff/4.png" alt="" onclick="reduceBar(this)">
                                                                </div>
                                                            </div>
                                                            <ul class="nav-rank-content three">
                                                                <li></li>
                                                            </ul>
                                                        </li>
                                                    </ul>
                                                    </text>
                                                }
                                            }

                                        </li>
                                    </ul>
                                </text>
            }
        }
    }
}
            </div>
        </div>
        <div class="container-rgt">
            <div class="content-list">
                <div class="list-header">
                    <div class="list-header-tp">
                        <div class="list-header-tp-lft">
                            深圳企动网络有限公司（@Model.PageModel.TotalCount 人）
                        </div>
                        <div class="list-header-tp-rgt">
                            <span onclick="addBar(this)">添加部门名称</span>
                            <span onclick="addBar(this)">添加子部门</span>
                        </div>
                    </div>
                    <div class="list-header-mid">
                        <div class="list-header-mid-lft">
                            <div class="list-header-mid-lft-item onitem">
                                <a href="@Url.Action("AddStaffTemplate","Staff")">
                                    添加成员
                                </a>
                            </div>
                            <div class="list-header-mid-lft-item">
                                批量导入
                            </div>
                            <div class="list-header-mid-lft-item">
                                同步
                            </div>
                            <div class="list-header-mid-lft-item">
                                <a href="javascript:void(0)" delUrl="@Url.Action("DeleteStaffTemplateAll")" class="batch batchDel">批量删除</a>
                            </div>
                        </div>
                        <div class="list-header-mid-rgt">
                            <img src="/admin_store/images/staff/5.png" alt="">
                            <span>申请扩容</span>
                        </div>
                    </div>
                    <div class="list-header-btm">
                        @*<input class="list-header-btm-ipt" type="text" name="" value="" placeholder="请输入姓名搜索">*@
                        @Html.TextBox("NickName",Model.staffName,new { @class="list-header-btm-ipt"})
                        <div class="list-btn">
                            <input id="SearchOrder" name="SearchOrder" type="image" class="searchBut submit" src="/admin_store/images/s.jpg" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="tan" id="addBar">
        <div class="mu"></div>
        <div class="window">
            <div class="window-header">
                <div class="">
                    增加部门
                </div>
                <img src="/admin_store/images/staff/4.png" alt="" onclick="closeWind()">
            </div>
            <div class="window-body">
                <div class="" style="margin-right:10px;font-size:14px;">
                    <span style="color:red">*</span>名称
                </div>
                <input class="window-body-ipt" type="text" id="addname" value="">
                <input type="hidden" name="parentId" id="parentId" value="0" />
            </div>
            <div class="window-foot">
                <div class="window-close" onclick="closeWind()">
                    取消
                </div>
                <div class="window-check" onclick="okWind()">
                    确认
                </div>
            </div>
        </div>
    </div>
    <div class="tan" id="changeBar">
        <div class="mu"></div>
        <div class="window">
            <div class="window-header">
                <div class="">
                    修改部门
                </div>
                <img src="/admin_store/images/staff/4.png" alt="" onclick="closeWind()">
            </div>
            <div class="window-body">
                <div class="" style="margin-right:10px;font-size:14px;">
                    <span style="color:red">*</span>名称
                </div>
                    <input class="window-body-ipt" type="text" id="updatename" value="">
                <input type="hidden" name="nameId" id="nameId" value="0" />
            </div>
            <div class="window-foot">
                <div class="window-close" onclick="closeWind()">
                    取消
                </div>
                <div class="window-check" onclick="okWind()">
                    确认
                </div>
            </div>
        </div>
    </div>
    <div class="tan" id="reduceBar">
        <div class="mu"></div>
        <div class="window" style="height:180px;width:420px;">
            <div class="window-header">
                <div class="">
                    提示
                </div>
                <img src="/admin_store/images/staff/4.png" alt="" onclick="closeWind()">
            </div>
            <div class="window-body" style="height:80px;">
                <div class="reduce" style="margin-right:10px;font-size:18px;">
                    <img src="/admin_store/images/staff/5.png" alt=""> 是否删除此部门
                </div>
                <input type="hidden" name="delId" id="delId" value="0" />
            </div>
            <div class="window-foot">
                <div class="window-close btn-rec" onclick="closeWind()">
                    取消
                </div>
                <div class="window-check btn-rec" onclick="delWind()">
                    确认
                </div>
            </div>
        </div>
    </div>
    <div class="dataList">
        <table width="100%">
            <thead>
                <tr>
                    <th style="width:3%;" align="center"><input type="checkbox" id="allSelect" /></th>
                    <th align="left">头像</th>
                    <th width="100" align="left">姓名</th>
                    <th width="140">职位</th>
                    <th width="80" align="left">部门</th>
                    <th width="80" align="left">手机</th>
                    <th width="96" align="left">管理操作</th>
                </tr>
            </thead>
            <tbody>

                @foreach (Staff row in Model.staffList)
                {
                    <tr data-id="@row.Id">
                        <td align="center"><input type="checkbox" value="@row.Id" selectItem="true" name="pidList" /></td>
                        <td>
                            <img class="logo" data-src="@row.Avater"/>
                        </td>
                        <td>@row.Name</td>
                        <td>@row.Position</td>
                        <td>@row.Department</td>
                        <td>@row.Phone</td>
                        <td>
                            @Html.ActionLink("编辑", "EditStaffTemplate", new { Id = row.Id }, new { @class = "editOperate" })&nbsp;|&nbsp;
                            @Html.ActionLink("删除", "DeleteStaffTemplate", new { Id = row.Id }, new { @class = "deleteOperate" })
                        </td>
                    </tr>
                                }
            </tbody>
        </table>
    </div>
<div class="dataListEdit">
<div class="page">
    @Html.StoreAdminPager(Model.PageModel)
</div>
</div>
}

<script type="text/javascript">

    $(function () {
        loadBtn();
    })

    function loadBtn() {
        $(".logo").each(function () {
            var avater = formatAvater($(this).attr("data-src"));
            $(this).attr("src", avater);            
        })


        $('.nav-rank-name').on('click', function () {
            $(this).addClass('on');
            $(".nav-rank-name").not($(this)).removeClass('on');
        });
        $('.nav-rank-img').on('click', function () {
            $(this).toggleClass('rotate_img');
            $(this).parent().siblings().slideToggle(50);
        }).click();
        $('.list-header-mid-lft-item').on('click', function () {
            $(this).addClass('onitem').siblings().removeClass('onitem');
        });

    }

    function addBar(obj) {
        $('#addBar').css('display', 'block');
        var ds = $(obj.parentElement.parentElement);
        console.log(ds[0].dataset["id"])
        $('#parentId').val(ds[0].dataset["id"]);
    };

    function changeBar(obj) {
        $('#changeBar').css('display', 'block');
        var ds = $(obj.parentElement.parentElement);
        $('#updatename').val(ds[0].outerText);
        console.log(ds[0].dataset["id"])
        $('#nameId').val(ds[0].dataset["id"]);
        
    };

    function reduceBar(obj) {
        $('#reduceBar').css('display', 'block');
        var ds = $(obj.parentElement.parentElement);
        $('#delId').val(ds[0].dataset["id"]);
    };

    function closeWind() {
      $('.tan').css('display', 'none');
    }

    function okWind() {
        var ids = $('#nameId').val();
        if (ids != 0) {//修改
            $.ajax({
                url: 'UpdateDepartment',
                type: 'post',
                data: {
                    "Id": ids,
                    "value": $('#updatename').val()
                },
                success: function (data) {
                    window.location.reload();
                }
            });
        } else {
            //添加
            $.ajax({
                url: 'AddDepartment',
                type: 'post',
                data: {
                    "ParentId": $('#parentId').val(),
                    "Name": $('#addname').val()
                },
                success: function (data) {
                    window.location.reload();
                }
            });
        }
    }

    function delWind() {
        $.ajax({
            url: 'DeleteDepartment',
            type: 'post',
            data: {
                "Id": $('#delId').val()
            },
            success: function (data) {
                window.location.reload();
            }
        });
    }


</script>
}